<?php if(!defined('BASEPATH')) exit('No direct script access allowed');

class common{
	public function GetUrlContent($url,$key,$secret,$type,$code,$uri){
		$data = array ('client_id' => $key,
			'client_secret' => $secret,
			'grant_type' => $type,
			'code' => $code,
			'redirect_uri' => $uri
		);
		$data = http_build_query($data);

		$params = array('http' => array(
			'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
			                . "Content-Length: " . strlen($data) . "\r\n",
			'method' => 'POST',
			'content' => $data
		));
		
		//if ($optional_headers !== null) {
			//$params['http']['header'] = 'application/x-www-form-urlencoded';
			//}
		
		$ctx = stream_context_create($params);
		$fp = @fopen($url, 'rb', false, $ctx);
		$response = @stream_get_contents($fp);

		return $response;
	}
}
	
/*End of file common.php*/